<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
<div id="app">
    <test-com></test-com>
</div>

</body>

</html>
<!-- 组件结构 -->
<template id="test">
    <fieldset>
        <legend>组件递归</legend>
        <h1>递归了{{count}}次</h1>
        <wq v-if="count<300" :count="count+1"></wq>
    </fieldset>
</template>
<script src='https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js'></script>
<script>

    //一般情况下需要通过v-if配合条件来控制递归的次数

    Vue.component('test-com', {
        template: `#test`,
        //这个name属性就是当前组件的标识,可以递归展示自己
        name: 'wq',
        //这个props就是以后的条件
        props: {
            count: {
                type: Number,
                //默认值
                default() {
                    return 1
                }
            }
        }

    })


    let vm = new Vue({
        el: "#app"
    })
</script>